/*
 * @description: 
 * @Date: 2022-10-05 15:13:53
 * @LastEditTime: 2022-12-20 16:35:45
 */
import axios from "axios";
import cache from "./cache";
import sm from "./sm2";
const apiHost = import.meta.env.VITE_APP_BASE_API;
const request = axios.create({ baseURL: apiHost });
async function ajax(params) {
  if (!params["headers"]) {
    params["headers"] = {}
  }
  Object.assign(params.headers, {
    Uid: cache.get("user_id"),
    Token: sm.encode(cache.get("token", ''))
  })
  try {
    let info = await request(params)
    return info.data;
  } catch (error) {
    return { code: 404 }
  }
}
export { apiHost }
export default ajax;